package org.example.B_100;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * 拔河比赛
 */
public class TugOfWar {
    public static void main(String[] args) {
        //输入
        Scanner sc = new Scanner(System.in);

        ArrayList<Employee> employees = new ArrayList<>();

        //没有额外的空行作为输入结束条件
        while (sc.hasNextLine()){
            employees.add(new Employee(sc.nextLine()));
        }

        getResult(employees);
    }

    public static void  getResult(ArrayList<Employee> employees){
        employees.sort((a,b) -> a.height != b.height ? b.height - a.height : b.weight - a.weight);

        for (int i = 0; i < 10; i++) {
            System.out.println(employees.get(i));
        }
    }

    static class Employee{
        int height;
        int weight;

        public Employee(String s ){
            int[] tmp = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();
            this.height = tmp[0];
            this.weight = tmp[1];
        }

        @Override
        public String toString() {
            return this.height + " " + this.weight;
        }
    }
}
